package com.buddy.sds.auth.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.buddy.sds.auth.entity.SystemUser;
import com.buddy.sds.common.mybatis.RedisCache;
import org.apache.ibatis.annotations.*;

@Mapper
public interface ISystemUserMapper extends BaseMapper<SystemUser> {
    @Select("select exists(select user_name from t_system_user where user_name = #{name})")
    boolean existsUsername(String username);

    @Delete("delete from t_system_user_role where ur_user=#{uid}")
    void deleteUserRoleByUser(String userId);

    @Delete("delete from t_system_user_role where ur_role=#{rid}")
    void deleteUserRoleByRole(String roleId);

    @Insert("insert into t_system_user_role(ur_id,ur_user,ur_role) values(#{uuid} ,#{user_id},#{role_id})")
    void addUserRole(@Param("uuid")String uuid,@Param("user_id")String user_id,@Param("role_id")String rid);

    @Update("update t_system_user set user_password=#{newPassword} where user_id=#{userId}")
    void updatePasaword(@Param("userId") String userId, @Param("newPassword") String newPassword);

}
